home *** CD-ROM | disk | FTP | other *** search
/ Internet Info 1994 March / Internet Info CD-ROM (Walnut Creek) (March 1994).iso / networking / news / misc / newsxd-2.5.1-shar / defs.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-06-08  |  6.6 KB  |  211 lines

  1. /* Define everything that all of the various pieces of code will be using */
  2.  
  3. #include <stdio.h>
  4. #include <signal.h>
  5. #include <strings.h>
  6. #include <syslog.h>
  7. #include <nlist.h>
  8. #include <errno.h>
  9. #include <ctype.h>
  10. #include <sys/param.h>
  11. #include <sys/errno.h>
  12. #include <sys/file.h>
  13. #include <sys/ioctl.h>
  14. #include <sys/wait.h>
  15. #include <sys/types.h>
  16. #include <sys/stat.h>
  17. #include <varargs.h>
  18.  
  19. #include "newsxd.h"
  20. #include "patchlevel.h"
  21.  
  22. /* If it's good enough for news 2.11, it's good enough for me ... */
  23.  
  24. #ifdef BSD4_2
  25. #include <sys/time.h>
  26. #else
  27. #include <time.h>
  28. #endif
  29.  
  30. #include <sys/resource.h>
  31.  
  32. #if defined(mips) & defined(ultrix)
  33. #include <sys/../h/fixpoint.h>
  34. #endif
  35.  
  36. char    *calloc();
  37.  
  38. #define foreach(ctl, list) for (ctl = list; ctl != NULL; ctl = ctl->next)
  39.  
  40. #ifdef    CNEWSLOCKING
  41. extern char    *progname;
  42. #endif
  43.  
  44. int     debug,                  /* is debugging enabled                       */
  45.         DEBUG,                  /* painfully verbose debugging is enabled     */
  46.         newsxdebug,             /* run xmitter synchronously with debugging?  */
  47.         tallying,               /* is use of a tally file enabled?            */
  48.         locking,                /* is use of a locking file enabled?          */
  49.         CONFIGCHANGED,          /* a new configuration was read in            */
  50. #ifdef FAKESYSLOG
  51.         CONFIGCHANGEDFILE,      /* a new configuration was read in            */
  52. #endif
  53.         queueinterval,          /* number of seconds between xmit checks      */
  54.     daemon_idle,        /* prevent newsxd from running queue if set   */
  55.         pidlist[MAXXMITTERS];   /* map pid --> xmitter quicker                */
  56.  
  57. struct    host    *pidmap[MAXXMITTERS];
  58.  
  59. char    batchfile[MAXPATHLEN],  /* file inews places article IDs/paths in     */
  60.         workfile[MAXPATHLEN],   /* file to use for transmitter work file      */
  61.         xmitlogs[MAXPATHLEN],   /* where to log the output of transmitters    */
  62.         tallyfile[MAXPATHLEN],  /* where the tally file can be found          */
  63.         statusfile[MAXPATHLEN], /* where newsxd's status should be written    */
  64.         pidfile[MAXPATHLEN],    /* where newsxd's pid should be written       */
  65. #ifdef FAKESYSLOG
  66.         fakelogfile[MAXPATHLEN],/* where is the newsxd log file?              */
  67. #endif
  68.         configfile[MAXPATHLEN]; /* where is the newsxd configuration file?    */
  69.  
  70. /* STRUCT OPTIONS
  71.  * Used to define the options controlling the starting of transmitters for
  72.  * classes and hosts.
  73.  *
  74.  * interval   : minimum start-to-start interval for each host's transmitter
  75.  * startint   : minimum interval between starting transmitters in this class
  76.  * ttl        : maximum time-to-live (secs) for a transmitter in this class
  77.  * ttlpenalty : penalty time (secs) for a transmitter exceeding the ttl
  78.  * deltanice  : amount to change nice before execing the transmitter
  79.  * maxload    : maximum load where new xmitters can be started for this class
  80.  *
  81.  */
  82.  
  83. typedef struct options {
  84.  
  85.     int    deltanice;
  86.     int    interval;
  87.     int    startint;
  88.     int    ttl;
  89.     int    ttlpenalty;
  90.     int    maxload;
  91.     
  92. };
  93.  
  94. /*
  95.  * STRUCT CLASS
  96.  * Contains the current state and description of each class of transmitters
  97.  * that newsxd handles.
  98.  *
  99.  * classname  : textual name of this transmission class
  100.  * maxxmits   : maximum number of simultaneous transmitters for this class
  101.  * curxmits   : current number of active transmitters for this class
  102.  * laststart  : last time a transmitter was started for this class
  103.  * xmitsernum : transmission serial number used for fair news transmission
  104.  * options    : defines default transmitter startup parameters for this class
  105.  * members    : number of hosts that are a member of this class
  106.  * flags      : special option flags for this class
  107.  *                0 : don't rename <batchfile> to <workfile>
  108.  *                1 : don't look for <batchfile> or <workfile>
  109.  * xpath      : file path for an alternate transmission program
  110.  * xargv      : arguments to be passed to the alternate transmitter
  111.  * xargc      : number of arguments to be passed to the alternate xmitter
  112.  * valid      : used to detect which classes are valid after a config update
  113.  * next       : pointer to the next class descriptor in the list
  114.  *
  115.  */
  116.  
  117. struct  class {
  118.  
  119.         char    classname[MAXCLASSNAMELEN];
  120.         int     maxxmits;
  121.         int     curxmits;
  122.         int     laststart;
  123.         int     xmitsernum;
  124.         int     members;
  125.     struct    options    options;
  126.     char    slots[MAXCLASSXMITTERS];
  127.         int     flags[MAXCLASSFLAGS];
  128.     char    batchfile[MAXPATHLEN];
  129.     char    workfile[MAXPATHLEN];
  130.         char    xpath[MAXPATHLEN];
  131.         char    *xargv[MAXEXECARGS];
  132.         int     xargc;
  133.         char    *debugargv[MAXEXECARGS];
  134.         int     debugargc;
  135.         int     valid;
  136.         struct  class   *next;
  137.  
  138. };
  139.  
  140. /*
  141.  * STRUCT HOST
  142.  * Contains the current state and description of each host that newsxd
  143.  * will be communicating with.
  144.  *
  145.  * hostname    : name of the host to pass to the transmitter
  146.  * class       : name of the transmission class this host is in
  147.  * times       : list of valid times to transmit in UUCP L.sys format
  148.  * pid         : pid of forked transmitter
  149.  * lasttime    : last time transmitter was forked off
  150.  * xmitsernum  : transmission serial number used for fair news transmission
  151.  * penaltytime : host xmitted to past ttl; secs before penalty is over
  152.  * whynot      : why is there no transmitter running for this host NOW?
  153.  * valid       : used to detect which hosts are valid after a config update
  154.  * options     : defines default transmitter startup parameters for this host
  155.  * next        : pointer to next host in the list of all hosts
  156.  * xargv       : arguments to be passed to the transmitter
  157.  * xargc       : number of arguments to be passed to the transmitter
  158.  *
  159.  */
  160.  
  161. struct  host {
  162.  
  163.         char    hostname[MAXHOSTNAMELEN];
  164.         char    class[MAXCLASSNAMELEN];
  165.         char    times[MAXTIMENAMELEN];
  166.         int     pid;
  167.         int     lasttime;
  168.         int     penaltytime;
  169.         int     xmitsernum;
  170.         int     whynot;
  171.         int     valid;
  172.     int    classslot;
  173.     struct    options    options;
  174.         char    *xargv[MAXEXECARGS];
  175.         int     xargc;
  176.         struct  host    *next;
  177.  
  178. };
  179.  
  180. struct  class   *classlist;
  181. struct  host    *hostlist;
  182.  
  183. /* Predefine the return types of all of the functions */
  184.  
  185. void    addclass();
  186. void    addhost();
  187. void    clear_invalid();
  188. void    daemon_start();
  189. void    debug_off();
  190. void    debug_on();
  191. void    dprintf();
  192. void    Dprintf();
  193. void    dump_config();
  194. void    dump_info();
  195. void    idle();
  196. void    reset();
  197. struct    class    *getclass();
  198. void    freeclassslot();
  199. int    getclassslot();
  200. int    getla();
  201. void    kill_children();
  202. void    log();
  203. void    logerr();
  204. void    make_invalid();
  205. int    parsetime();
  206. void    processarg();
  207. void    read_config();
  208. void    run_queue();
  209. int    validtime();
  210. void    xmit_done();
  211.